extends Area2D

@export var speed:Vector2 = Vector2(5,0)
var init_position 

func _ready():
	add_to_group("ball")
	init_position = position

func _process(delta):
	position = position + speed

func init_positio():
	if speed.x > 0:
		Score.score_left += 1
		create_flame(1080,position.y)
	else:
		create_flame(0,position.y)
		Score.score_right += 1
	position = init_position
	
func create_flame(x,y):
	var flame = load("res://animate/flame.tscn")   
	var flame_instance = flame.instantiate() 
	get_parent().add_child(flame_instance)
	flame_instance.play()
	flame_instance.position = Vector2(x,y)
